<?php

namespace app\admin\validate;

use think\Validate;

class Admin extends Validate
{
    protected $rule = [
        'true_name|真实姓名' => 'require|length:2,20',
        'name|账号' => 'require|length:2,20|unique:admin',
        'password|密码' => 'verifyPassword:thinkphp'
    ];



    protected function verifyPassword($value, $rule, $data)
    {
        if (empty($data['id']) && empty($value))
            return '请输入密码';
        $strlen = strlen($value);
        if ($value && ($strlen < 6 || $strlen > 12))
            return '密码长度位6-12位';
        return true;
    }



}

